home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -serious- / programming / c / icu-1.3.1 / icu-bin / include / putil.h < prev    next >
C/C++ Source or Header  |  2000-02-23  |  6KB  |  148 lines

  1. /*
  2. *******************************************************************************
  3. *                                                                             *
  4. * COPYRIGHT:                                                                  *
  5. *   (C) Copyright Taligent, Inc.,  1997                                       *
  6. *   (C) Copyright International Business Machines Corporation,  1997-1999     *
  7. *   Licensed Material - Program-Property of IBM - All Rights Reserved.        *
  8. *   US Government Users Restricted Rights - Use, duplication, or disclosure   *
  9. *   restricted by GSA ADP Schedule Contract with IBM Corp.                    *
  10. *                                                                             *
  11. *******************************************************************************
  12. *
  13. *  FILE NAME : putil.h
  14. *
  15. *   Date        Name        Description
  16. *   05/14/98    nos         Creation (content moved here from utypes.h).
  17. *   06/17/99    erm         Added IEEE_754
  18. *   07/22/98    stephen     Added IEEEremainder, max, min, trunc
  19. *   08/13/98    stephen     Added isNegativeInfinity, isPositiveInfinity
  20. *   08/24/98    stephen     Added longBitsFromDouble
  21. *   03/02/99    stephen     Removed openFile().  Added AS400 support.
  22. *   04/15/99    stephen     Converted to C
  23. *******************************************************************************
  24. */
  25.  
  26. #ifndef PUTIL_H
  27. #define PUTIL_H
  28.  
  29. #include "utypes.h"
  30.  
  31. /* Define this if your platform supports IEEE 754 floating point */
  32. #define IEEE_754       
  33.  
  34. /*===========================================================================*/
  35. /* Platform utilities                                                        */
  36. /*===========================================================================*/
  37.  
  38. /**
  39.  * Platform utilities isolates the platform dependencies of the
  40.  * libarary.  For each platform which this code is ported to, these
  41.  * functions may have to be re-implemented.  */
  42.  
  43. /* Floating point utilities */
  44. U_CAPI bool_t  U_EXPORT2  icu_isNaN(double);
  45. U_CAPI bool_t  U_EXPORT2 icu_isInfinite(double);
  46. U_CAPI bool_t   U_EXPORT2 icu_isPositiveInfinity(double);
  47. U_CAPI bool_t   U_EXPORT2 icu_isNegativeInfinity(double);
  48. U_CAPI double   U_EXPORT2 icu_getNaN(void);
  49. U_CAPI double   U_EXPORT2 icu_getInfinity(void);
  50.  
  51. U_CAPI double   U_EXPORT2 icu_floor(double x);
  52. U_CAPI double   U_EXPORT2 icu_ceil(double x);
  53. U_CAPI double   U_EXPORT2 icu_fabs(double x);
  54. U_CAPI double   U_EXPORT2 icu_modf(double x, double* y);
  55. U_CAPI double   U_EXPORT2 icu_fmod(double x, double y);
  56. U_CAPI double   U_EXPORT2 icu_pow10(int32_t x);
  57. U_CAPI double   U_EXPORT2 icu_IEEEremainder(double x, double y);
  58. U_CAPI double   U_EXPORT2 icu_fmax(double x, double y);
  59. U_CAPI double   U_EXPORT2 icu_fmin(double x, double y);
  60. U_CAPI int32_t  U_EXPORT2 icu_max(int32_t x, int32_t y);
  61. U_CAPI int32_t  U_EXPORT2 icu_min(int32_t x, int32_t y);
  62. U_CAPI double   U_EXPORT2 icu_trunc(double d);
  63. U_CAPI void     U_EXPORT2 icu_longBitsFromDouble(double d, int32_t *hi, uint32_t *lo);
  64.  
  65. /*
  66.  * Return the floor of the log base 10 of a given double.
  67.  * This method compensates for inaccuracies which arise naturally when
  68.  * computing logs, and always gives the correct value.  The parameter
  69.  * must be positive and finite.
  70.  * (Thanks to Alan Liu for supplying this function.)
  71.  */
  72. /**
  73.  * Returns the common log of the double value d.
  74.  * @param d the double value to apply the common log function for.
  75.  * @return the log of value d.
  76.  */
  77. U_CAPI int16_t  U_EXPORT2 icu_log10(double d);
  78.  
  79. /**
  80.  * Returns the number of digits after the decimal point in a double number x.
  81.  * @param x the double number
  82.  */
  83. U_CAPI int32_t  U_EXPORT2 icu_digitsAfterDecimal(double x);
  84.  
  85. /**
  86.  * Time zone utilities
  87.  *
  88.  * Wrappers for C runtime library functions relating to timezones.
  89.  * The t_tzset() function (similar to tzset) uses the current setting 
  90.  * of the environment variable TZ to assign values to three global 
  91.  * variables: daylight, timezone, and tzname. These variables have the 
  92.  * following meanings, and are declared in <time.h>.
  93.  *
  94.  *   daylight   Nonzero if daylight-saving-time zone (DST) is specified
  95.  *              in TZ; otherwise, 0. Default value is 1.
  96.  *   timezone   Difference in seconds between coordinated universal
  97.  *              time and local time. E.g., -28,800 for PST (GMT-8hrs)
  98.  *   tzname(0)  Three-letter time-zone name derived from TZ environment
  99.  *              variable. E.g., "PST".
  100.  *   tzname(1)  Three-letter DST zone name derived from TZ environment
  101.  *              variable.  E.g., "PDT". If DST zone is omitted from TZ,
  102.  *              tzname(1) is an empty string.
  103.  *
  104.  * Notes: For example, to set the TZ environment variable to correspond
  105.  * to the current time zone in Germany, you can use one of the
  106.  * following statements:
  107.  *
  108.  *   set TZ=GST1GDT
  109.  *   set TZ=GST+1GDT
  110.  *
  111.  * If the TZ value is not set, t_tzset() attempts to use the time zone
  112.  * information specified by the operating system. Under Windows NT
  113.  * and Windows 95, this information is specified in the Control Panel’s
  114.  * Date/Time application.
  115.  */
  116. U_CAPI void     U_EXPORT2 icu_tzset(void);
  117. U_CAPI int32_t  U_EXPORT2 icu_timezone(void);
  118. U_CAPI char*    U_EXPORT2 icu_tzname(int index);
  119.  
  120. /* Get UTC (GMT) time measured in seconds since 0:00 on 1/1/70. */
  121. U_CAPI int32_t  U_EXPORT2 icu_getUTCtime(void);
  122.  
  123. /* Return the default data directory for this platform.  See Locale. */
  124. U_CAPI const char*  U_EXPORT2 icu_getDefaultDataDirectory(void);
  125.  
  126. /* Return the default codepage for this platform and locale */
  127. U_CAPI const char*  U_EXPORT2 icu_getDefaultCodepage(void);
  128.  
  129. /* Return the default locale ID string by querying ths system, or
  130.        zero if one cannot be found. */
  131. U_CAPI const char*  U_EXPORT2 icu_getDefaultLocaleID(void);
  132.  
  133. /*
  134.  * Finds the least double greater than d (if positive == true),
  135.  * or the greatest double less than d (if positive == false).
  136.  *
  137.  * This is a special purpose function defined by the ChoiceFormat API
  138.  * documentation.
  139.  * It is not a general purpose function and not defined for NaN or Infinity
  140.  */
  141. U_CAPI double           U_EXPORT2 icu_nextDouble(double d, bool_t positive);
  142.  
  143. #endif
  144.  
  145.  
  146.  
  147.  
  148.